home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
util1
/
stelcd10.lha
/
StealCD.mod
< prev
Wrap
Text File
|
1995-08-28
|
3KB
|
153 lines
(*************************************************************************
:Program. StealCD
:Version. V1.0 (28.08.95)
:Contents. see --background--
:Author. Jan Hense [juh]
:Address. Milchstr. 4, 81667 München, Germany
:Address. Tel. +49-89-481960, e-mail j.hense@amc.cube.net
:Copyright.
:Language. Oberon (with Amiga Oberon extensions)
:Translator. Amiga Oberon v3.00d
**************************************************************************)
MODULE StealCD;
IMPORT
Dos, Exec, SYSTEM;
(*
******* StealCD/--background-- *******************************************
*
* NAME
*
* StealCD
*
* SYNOPSIS
*
* StealCD PROCESS/N/A
*
* DESCRIPTION
*
* Peeks the name of the current directory of another process and
* echos it to the standard output. To actually use it I recommend an
* alias of the form
*
* ALIAS scd "CD *`StealCD []*`"
*
* in your s:shell-startup.
*
* OPTIONS
*
* PROCESS - the number of another process as returned by the status
* cli command or the shell variable $process.
*
* AUTHOR
*
* Jan Hense
* Milchstr. 4
* 81667 München, Germany
* Tel. +49-89-481960
* e-mail j.hense@amc.cube.net
*
* COPYRIGHT
*
* Freely distributable
*
**************************************************************************
*
*)
(*
******* StealCD/--history-- **********************************************
*
* v1.0 (28.08.95) [juh]
*
* Created initial version.
*
**************************************************************************
*
* TO DO
*
*)
CONST
template = "PROCESS/N/A"
"\o$VER: StealCD 1.0 (28.08.95) ©1995 j.hense@amc.cube.net";
noSuchProcess = "No such process!\n";
TYPE
ArgsStruct = STRUCT (as: Dos.ArgsStruct)
process: UNTRACED POINTER TO LONGINT;
END;
VAR
rda: Dos.RDArgsPtr;
args: ArgsStruct;
process: Dos.ProcessPtr;
buffer: ARRAY 256 OF CHAR;
success: BOOLEAN;
(* Convert a BSTR to a normal string *)
PROCEDURE BstrToString(from: Dos.BSTR;
VAR to: ARRAY OF CHAR;
VAR success: BOOLEAN);
VAR
i, len: INTEGER;
BEGIN
success := FALSE;
len := ORD(from[0]);
IF LEN(to) > len THEN
FOR i := 1 TO len DO
to[i-1] := from[i];
END;
to[len] := 0X;
success := TRUE;
END;
END BstrToString;
(************************************************************************)
BEGIN
rda := Dos.ReadArgs(template, args, NIL);
Exec.Forbid;
process := Dos.FindCliProc(args.process^);
IF process=NIL THEN
Exec.Permit;
Dos.PrintF(noSuchProcess);
HALT(10);
END;
BstrToString(process.cli.setName, buffer, success);
Exec.Permit;
IF ~success THEN
HALT(10);
END;
Dos.PrintF(buffer); Dos.PrintF("\n");
CLOSE
Dos.FreeArgs(rda);
END StealCD.